#include"function actualize.h"
bool Delete_Next_Node(Link LinkNode, LinkList *pLink)
{
	Link L = LinkNode;
	L = LinkNode->next;
	if (LinkNode->next->next == NULL)
	{
		LinkNode->next = NULL;
		pLink->end = LinkNode;
		delete[]L;
		return EXIT_SUCCESS;
	}
	LinkNode->next = LinkNode->next->next;
	delete[]L;
	return EXIT_SUCCESS;
}
bool InsertLNode(LinkList *pLink, ElemType e)
{
	Link p = pLink->head;
	Link ins = (Link)malloc(sizeof(LNode));
	if (!ins) { cout << "ERROR!"; }
	ins->data = e;
	if (p->next == NULL) 
	{ 
		p->next = ins; 
		ins->next = NULL; 
		pLink->end = ins; 
		return EXIT_SUCCESS; 
	}
	while (p->next->data.power < e.power)
	{
		if (p->next->next == NULL)
			break;
		p = p->next;
	}
	if (e.power == p->next->data.power)
	{ 
		p->next->data.oeffi += e.oeffi;
		if (p->next->data.oeffi == 0) 
		{ 
			Delete_Next_Node(p, pLink); 
		}
		return EXIT_SUCCESS;
	}
	if (p->next->next == NULL) 
	{ 
		p->next->next = ins; 
		ins->next = NULL; 
		pLink->end = ins; 
		return EXIT_SUCCESS; 
	}
	else 
	{ 
		ins->next = p->next; 
		p->next = ins; 
		return EXIT_SUCCESS; 
	}
	return EXIT_FAILURE;
}